package com.jos.appium;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.windows.WindowsDriver;

public class WindowWechat {

	public static void main(String[] args) {

		WindowWechat model = new WindowWechat();

		try {
			model.exce();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public void exce() throws MalformedURLException, InterruptedException {
		DesiredCapabilities appCapabilities = new DesiredCapabilities();
		appCapabilities.setCapability("app", "D:/Program Files (x86)/Tencent/WeChat/WeChat.exe");
		appCapabilities.setCapability("deviceName", "WindowsPC");
		appCapabilities.setCapability("platformName", "windows");
		appCapabilities.setCapability("sessionOverride", true);
		appCapabilities.setCapability("noReset", true);
		appCapabilities.setCapability("fullReset", false);
		appCapabilities.setCapability("unicodeKeyboard", true);
		appCapabilities.setCapability("newCommandTimeout", "30000");
		appCapabilities.setCapability("showChromedriverLog", true);
		appCapabilities.setCapability("recreateChromeDriverSessions", "True");

		WindowsDriver<WebElement> driver = new WindowsDriver<WebElement>(new URL("http://192.168.152.197:4723/wd/hub"),
				appCapabilities);

		Thread.sleep(1000 * 10);
		System.out.println("driver=" + driver);

		WebElement element = driver.findElement(By.name("输入"));
		System.out.println("element=" + element);
		Thread.sleep(1000 * 3);
		element.click();
		element.sendKeys("凯哥");
		
		Thread.sleep(1000 * 1);
		driver.findElement(By.name("发送(S)")).click();

	}

}
